<template>
  <div class="AddGoodsShop">
    <div class="ele-title">
      <h3>单门店商品设置</h3>
    </div>
    <div class="ele-store">
      <span class="ele-span-title">门店：</span>
      <div class="card-list">
        <el-card>
          <div slot="header" class="ele-card-header" />
          <div class="ele-content">
            <div class="left">
              <el-image
                :src="
                  shopUrl.includes('https')
                    ? shopUrl
                    : require('@/assets/images/shop.jpg')
                "
                alt=""
              />
            </div>
            <div class="right">
              <p>{{ shopName }}</p>
              <p>{{ shopAddress }}</p>
            </div>
          </div>
        </el-card>
      </div>
    </div>
    <div class="ele-store">
      <span class="ele-span-title">商品：</span>
      <div class="card-list">
        <el-card>
          <div class="ele-div--1">
            <div class="left"><el-image :src="commodityPic" alt="" /></div>
            <div class="right">
              <p>{{ commodityName }}</p>
              <p class="ele-type">类型:<span v-if="type==='lease'">租赁</span><span v-if="type==='sale'">售卖</span></p>
            </div>
          </div>
        </el-card>
      </div>
    </div>
    <h4>价格库存</h4>
    <div class="formModel">
      <el-form :model="BindForm" :rules="rules" label-width="100px" label-position="left">
        <el-form-item label="只支持医院" prop="onlyToHospital">
          <el-row :gutter="24">
            <el-col :span="20" style="padding-left: 0">
              <el-radio-group v-model="BindForm.onlyToHospital">
                <el-radio label="1">是</el-radio>
                <el-radio label="0">否</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="发货仓库:" prop="stock">
          <el-row :gutter="24">
            <el-col :span="2" style="padding-left: 0">
              <el-checkbox v-model="BindForm.deliverStore">门店仓库</el-checkbox>
            </el-col>
            <el-col :span="5">
              <el-input-number v-model="BindForm.goodsStock" :controls="false" :disabled="BindForm.deliverStore&&list&&list.length>0?false:true" :min="0" :max="1000000" :precision="0" placeholder="输入库存数量" />
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col
              :span="5"
              class="text"
            >无锁止，从门店仓库获取商品库存</el-col>
            <el-col
              :span="6"
              :offset="3"
            >如果多个发货仓库都有库存时，按以下顺序消耗库存，链条锁-医柜-门店仓-云仓</el-col>
          </el-row>

          <el-row :gutter="24">
            <el-col :span="2">
              <el-checkbox v-model="BindForm.chainLock">链条锁</el-checkbox>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col
              :span="5"
              class="text"
            >有锁止，从锁止设备上获取商品库存。</el-col>
          </el-row>

          <el-row :gutter="24">
            <el-col :span="2">
              <el-checkbox v-model="BindForm.cabinetLock">医柜</el-checkbox>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="5" class="text">从医柜获取库存。</el-col>
          </el-row>

          <el-row :gutter="24">
            <el-col :span="2">
              <el-checkbox v-model="BindForm.cloudLock">云仓</el-checkbox>
            </el-col>
          </el-row>
          <el-row v-if="BindForm.cloudLock" :gutter="24" type="flex" justify="start">
            <div v-for="(item,index) in cloudStoreList" :key="index" style="margin-right: 10px;">
              <el-card style="position: relative;width: 150px;border-radius: 10px;background-color: #F2F1F1">
                <span>{{ item.name }}</span>
                <el-button class="el-icon-close" circle type="danger" style="position: absolute;top: 0;right: 0;font-size: 14px;padding: 3px;" @click="delCloudStore(index)" />
              </el-card>
            </div>
            <el-button type="text" style="margin-left: 10px;" @click="addCloudStore">添加云仓</el-button>
          </el-row>
        </el-form-item>
        <el-form-item v-if="type==='sale'" label="运费:">
          <el-row :gutter="24">
            <el-col :span="12">
              <el-checkbox v-model="BindForm.freeType">免运费服务</el-checkbox>
            </el-col>
          </el-row>
          <el-row v-show="BindForm.freeType" :gutter="24">
            <el-col :span="7">
              <el-radio-group v-model="BindForm.freeShip" type="flex">

                <el-radio label="1">免运费</el-radio>

                <el-radio label="2">消费满</el-radio>

                <el-input-number v-model="BindForm.freeCount" placeholder="请输入金额" :controls="false" style="width:200px" :min="0" :max="1000000" :precision="2" :disabled="BindForm.freeShip==='2'?false:true" />

              </el-radio-group>
            </el-col>
            <el-col :span="5">
              <span class="margin-left text">元免运费</span>
            </el-col>
            <el-col
              :span="6"
              class="text"
            >根据当前订单金额计算免运费条件的消费金额</el-col>
          </el-row>
        </el-form-item>
        <el-form-item v-else-if="type==='lease'" label="运费:">
          <el-row :gutter="24">
            <el-col :span="12">
              <el-checkbox v-model="BindForm.freeType">免运费服务</el-checkbox>
            </el-col>
          </el-row>
          <el-row v-show="BindForm.freeType" :gutter="24">
            <el-col :span="12">
              <el-col :span="15">
                <el-radio-group v-model="BindForm.freeShip">
                  <el-radio label="1">免送货费 </el-radio>
                  <el-radio label="2">消费满</el-radio><el-input-number v-model="BindForm.freeCount" :controls="false" :disabled="BindForm.freeShip==='2'?false:true" :min="0" :max="1000000" :precision="2" placeholder="请输入金额" style="width:200px" />
                </el-radio-group>
              </el-col>
              <el-col :span="9">
                <span class="margin-left text">元免送货费</span>
              </el-col>
              <el-col :span="15">
                <el-radio-group v-model="BindForm.freePick">
                  <el-radio label="1">免取货费 </el-radio>
                  <el-radio label="2">消费满</el-radio><el-input-number v-model="BindForm.freePickCount" :controls="false" :disabled="BindForm.freePick==='2'?false:true" :min="0" :max="1000000" :precision="2" placeholder="请输入金额" style="width:200px" />
                </el-radio-group>
              </el-col>
              <el-col :span="9">
                <span class="margin-left text">元免取货费</span>
              </el-col>
            </el-col>
            <el-col
              :span="6"
              class="text"
            >根据当前订单金额计算免运费条件的消费金额</el-col>
          </el-row>
        </el-form-item>
        <el-form-item v-if="type==='sale'" label="零售价格:">
          <el-row :gutter="24">
            <el-col :span="4">
              <div class="dispaly-flex">
                <el-input-number v-model="BindForm.retailPrice" :controls="false" :precision="2" :min="0" :max="1000000" :disabled="list&&list.length>0" placeholder="输入零售价格" /><span
                  class="margin-left"
                >元</span>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="5" class="text">用户实际购买价格</el-col>
          </el-row>
        </el-form-item>
        <el-form-item v-else-if="type==='lease'" label="收费方式:" prop="chargeId">
          <el-row :gutter="24">
            <el-col :span="4">
              <el-select v-model="BindForm.chargeId" @focus="showDialogCharge">
                <el-option
                  v-for="item in chargeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-col>
          </el-row>
        </el-form-item>

        <el-form-item label="运维费用:" prop="operateId">
          <el-row :gutter="24">
            <el-col :span="4">
              <el-select v-model="BindForm.operateId" @focus="showDialogOperate">
                <el-option
                  v-for="item in YWFOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-col>
          </el-row>
        </el-form-item>

        <el-form-item v-if="type=='lease'" label="是否回收" prop="isRecovery">
          <el-row :gutter="24">
            <el-col :span="23">
              <el-radio-group v-model="BindForm.isRecovery">
                <el-radio label="1">是</el-radio>
                <el-radio label="0">否</el-radio>
              </el-radio-group>
            </el-col>
            <el-col v-if="BindForm.isRecovery=='1'" :span="23" style="margin-bottom: 10px;">
              <el-form-item label="回收价格" prop="recoveryPrice">
                <el-input v-model="BindForm.recoveryPrice" style="width: 200px" />
              </el-form-item>

            </el-col>
            <el-col v-if="BindForm.isRecovery==1" :span="23" style="display: flex;justify-content: start;">
              <div v-for="(item,index) in collectionList" :key="index" style="margin-right: 10px;">
                <el-card style="position: relative;width: 150px;border-radius: 10px;background-color: #F2F1F1">
                  <span>{{ item.name }}</span>
                  <el-button class="el-icon-close" circle type="danger" style="position: absolute;top: 0;right: 0;font-size: 14px;padding: 3px;" @click="delCollection(index)" />
                </el-card>
              </div>
              <el-button type="text" style="margin-left: 10px;" @click="addCollection">添加回收点</el-button>
            </el-col>
          </el-row>
        </el-form-item>

        <el-form-item v-if="type=='lease'" label="免押状态" prop="noDepositStat">
          <el-row :gutter="24">
            <el-col :span="20">
              <el-radio-group v-model="BindForm.noDepositStat">
                <el-radio label="0">不支持信用免押</el-radio>
                <el-radio label="1">仅支持微信信用免押</el-radio>
                <el-radio label="2">仅支持支付宝信用免押</el-radio>
                <el-radio label="3">同时支持微信信用免押和支付宝信用免押</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
        </el-form-item>

        <el-form-item label="常规规格:" prop="regularSpec">
          <el-col :span="20">
            <div class="Specifications">
              <div class="cations-tag">
                <el-row v-for="(item, index) in list" :key="index">
                  <SpecItem ref="SpecItem" :index="index" :type="3" :table-head="item" />
                </el-row>
              </div>
            </div>
            <table v-show="list && list.length > 0" class="ele-spec-table">
              <thead>
                <tr v-if="theadList&&theadList.length>0">
                  <td v-for="(item,index) in theadList" :key="index">{{ item }}</td>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item,index) in tbodyList" :key="index">
                  <td v-for="(i,j) in item" v-show="i.val!==''" :key="j" :rowspan="i.rowspan">
                    <span v-show="i.val!=='salePrice'&&i.val!=='stock'&&i.val!=='deposit'">{{ i.val }}</span>
                    <GoodsDepositValue v-if="i.val==='deposit'" ref="GoodsDepositValue" :index="j" :commodity-id="regularProductId[index]" />
                    <goods-sale-price-value v-if="i.val==='salePrice'" ref="GoodsSalePriceValue" :change-disabled="changeDisable" :index="j" :commodity-id="regularProductId[index]" />
                    <goods-stock-value v-if="i.val==='stock'" ref="GoodsStockValue" :change-stock-disabled="changeStockDisable" :index="j" :commodity-id="regularProductId[index]" />
                  </td>
                </tr>
              </tbody>
            </table>
          </el-col>
        </el-form-item>

        <el-form-item v-if="extraList&&extraList.length>0" label="附加规格:" prop="extraRegularSpec">
          <el-col :span="20">
            <div class="Specifications">
              <div class="cations-tag">
                <!-- 附加规格栏目 -->
                <el-row v-for="(item, index) in extraList" :key="index">
                  <ExtraSpecItem ref="ExtraSpecItem" :type="3" :index="index" :table-head="item" />
                </el-row>
                <!-- 附加规格栏目 -->
              </div>

            </div>
            <table class="ele-spec-table">
              <thead>
                <tr>
                  <td>规格名</td>
                  <td>规格值</td>
                  <td>关联商品</td>
                  <td>零售价格</td>
                  <td>库存</td>
                </tr>
              </thead>
              <tbody v-for="(item,index) in extraTable" :key="index">
                <tr v-for="(inf,index1) in item.specValue" :key="index1">
                  <td v-if="index1===0" :rowspan="item.specValue.length">{{ item.specName }}</td>
                  <td>{{ inf.value }}</td>
                  <td>
                    <div v-if="inf.goods==='goods'">
                      <goods-info ref="goods-info" :index="index" :goods-id="inf.commodityid" />
                    </div>
                    <div v-if="inf.goods==='service'">
                      <service-info ref="serviceInfo" :index="index" :service-id="inf.commodityid" />
                    </div>
                  </td>
                  <td v-if="inf.salePrice==='salePrice'"><GoodsExtraSalePriceValue ref="GoodsExtraSalePriceValue" :index="index" :product-id="inf.commodityid" /></td>
                  <td v-if="inf.stock==='stock'"><GoodsExtraStockValue ref="GoodsExtraStockValue" :index="index" :product-id="inf.commodityid" /></td>
                </tr>
              </tbody>
            </table>
          </el-col>
        </el-form-item>
        <h4>物流设置</h4>
        <el-form-item label="配送费用:" prop="radio1">
          <el-row :gutter="24">
            <el-col :span="2" style="padding-left: 0">
              <el-radio v-model="radio1" label="0" @change="changeExpress">统一费用</el-radio>
            </el-col>
          </el-row>
          <el-row v-if="type == 'lease'" :gutter="24">
            <el-col :span="10">
              <el-radio-group v-model="TyIsAfterPay" :disabled="radio1==='0'?false:true">
                <el-radio label="0">先付费</el-radio>
                <el-radio label="1">后付费</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
          <el-row v-if="BindForm.cloudLock" :gutter="24">
            <el-col :span="2" class="left-end">
              <label>云仓物流</label>
            </el-col>
            <el-col :span="22">
              <el-col v-for="(item,index) in cloudStoreList" :key="index" :span="24">
                <CloudStoreExpress ref="cloudStoreExpress" :cloud-store="item" />
              </el-col>
            </el-col>
          </el-row>

          <el-row :gutter="24">
            <el-col :span="2" class="left-end">
              <label>同城送取</label>
            </el-col>
            <el-col :span="22">
              <el-col :span="1">配送</el-col>
              <el-col :span="23">
                <el-col :span="24">
                  <el-radio v-model="TySameCityDeliveryExpressType" label="0" :disabled="radio1==1">同城物流配送</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="4">
                    <el-select v-model="TySameCityDeliveryExpressCompany" :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='1') || radio1 == '1'">
                      <el-option
                        label="顺丰"
                        value="0"
                      >
                        顺丰
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6">
                    <el-input v-model="TySameCityDeliveryExpressCost" placeholder="输入费用" :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='1') || radio1 == '1'" />
                  </el-col>
                  <el-col :span="13" class="el-col-offset-1">
                    <el-form-item label="送达时间" class="sendTime">
                      <div style="display: flex;">
                        <el-form-item prop="TySameCityDeliverySendFastTime" label-width="0">
                          <el-input-number
                            v-model="TySameCityDeliverySendFastTime"
                            placeholder="输入最快送达时间"
                            :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='1') || radio1 == '1'"
                            :precision="0"
                            :controls="false"
                            :min="0"
                            :max="TySameCityDeliverySendSlowTime"
                          />
                        </el-form-item>
                        <span style="margin-left:20px;margin-right: 20px">至</span>
                        <el-form-item prop="TySameCityByselfSendSlowTime" class="sendTime" label-width="0">
                          <el-input-number
                            v-model="TySameCityDeliverySendSlowTime"
                            placeholder="输入最慢送达时间"
                            :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='1') || radio1 == '1'"
                            :precision="0"
                            :controls="false"
                            :min="TySameCityDeliverySendFastTime"
                            :max="24"
                          />
                        </el-form-item>
                        <span style="margin-left:20px">小时</span>
                      </div>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-radio v-model="TySameCityDeliveryExpressType" label="1" :disabled="radio1==1">同城自营骑手配送</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="6">
                    <el-input v-model="TySameCityDeliveryBySelfCost" placeholder="输入费用" :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='0') || radio1 == '1'" />
                  </el-col>
                  <el-col :span="14" class="el-col-offset-1">
                    <el-form-item label="送达时间" class="sendTime">
                      <div style="display: flex;">
                        <el-form-item prop="TySameCityByselfsendFastTime" label-width="0">
                          <el-input-number
                            v-model="TySameCityByselfsendFastTime"
                            placeholder="输入最快送达时间"
                            :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='0') || radio1 == '1'"
                            :precision="0"
                            :controls="false"
                            :min="0"
                            :max="TySameCityByselfsendSlowTime"
                          />
                        </el-form-item>
                        <span style="margin-left:20px;margin-right: 20px">至</span>
                        <el-form-item prop="TySameCityByselfsendSlowTime" class="sendTime" label-width="0">
                          <el-input-number
                            v-model="TySameCityByselfsendSlowTime"
                            placeholder="输入最慢送达时间"
                            :disabled="(radio1=='0' && TySameCityDeliveryExpressType=='0') || radio1 == '1'"
                            :precision="0"
                            :controls="false"
                            :min="TySameCityByselfsendFastTime"
                            :max="24"
                          />
                        </el-form-item>
                        <span style="margin-left:20px">小时</span>
                      </div>
                    </el-form-item>
                  </el-col>
                </el-col>
              </el-col>
              <el-col v-if="type=='sale'||(type=='lease' && BindForm.isRecovery=='0') || (type=='lease' && !BindForm.isRecovery)" :span="1">取回</el-col>
              <el-col v-if="type=='sale'||(type=='lease' && BindForm.isRecovery=='0') || (type=='lease' && !BindForm.isRecovery)" :span="23">
                <el-col :span="24">
                  <el-radio v-model="TySameCityRecoveryExpressType" label="0" :disabled="radio1==1">同城物流售后取回</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="4">
                    <el-select v-model="TySameCityRecoveryExpressCompanyId" :disabled="radio1==1 || (radio1==0 && TySameCityRecoveryExpressType==1)">
                      <el-option
                        label="顺丰"
                        value="0"
                      >
                        顺丰
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6">
                    <el-input v-model="TySameCityRecoveryExpressCost" placeholder="输入费用" :disabled="radio1==1 || (radio1==0 && TySameCityRecoveryExpressType==1)" />
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-radio v-model="TySameCityRecoveryExpressType" label="1" :disabled="radio1==1">同城自营骑手售后取回</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="6">
                    <el-input v-model="TySameCityRecoveryByselfCost" placeholder="输入费用" :disabled="radio1==1 || (radio1==0 && TySameCityRecoveryExpressType==0)" />
                  </el-col>
                </el-col>
              </el-col>
            </el-col>

          </el-row>

          <el-row :gutter="24" style="margin-top:20px">
            <el-col :span="2">
              <el-radio v-model="radio1" label="1" @change="changeExpress">运费模板</el-radio>
            </el-col>
          </el-row>
          <el-row v-if="type == 'lease'" :gutter="24">
            <el-col :span="24">
              <el-radio-group v-model="isModelAfterPay" :disabled="radio1==='1'?false:true">
                <el-radio label="0">先付费</el-radio>
                <el-radio label="1">后付费</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>

          <el-row v-if="BindForm.cloudLock" :gutter="24">
            <el-col :span="2" class="left-end">
              <label>云仓物流</label>
            </el-col>
            <el-col :span="22">
              <el-col v-for="(item,index) in cloudStoreList" :key="index" :span="24">
                <CloudStoreExpressModel ref="cloudStoreExpressModel" :cloud-store="item" />
              </el-col>
            </el-col>
          </el-row>

          <el-row :gutter="24">
            <el-col :span="2" class="left-end">
              <label>同城送取</label>
            </el-col>
            <el-col :span="22">
              <el-col :span="1" class="left-end">配送</el-col>
              <el-col :span="23">
                <el-col :span="24">
                  <el-radio v-model="modelSameCityDeliveryExpressType" label="0" :disabled="radio1=='0'">同城物流配送</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="4">
                    <el-select v-model="modelSameCityDeliveryExpressCompany" :disabled="radio1=='0'||(radio1=='1' && modelSameCityDeliveryExpressType=='1')">
                      <el-option
                        label="顺丰"
                        value="0"
                      >
                        顺丰
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6">
                    <el-select
                      ref="modelSameCityFreightId"
                      v-model="modelSameCityDeliveryFreightId"
                      :disabled="radio1=='0'||(radio1=='1' && modelSameCityDeliveryExpressType=='1')"
                      placeholder="选择运费模板"
                      style="width:200px"
                      @focus="showDialogYF(1,'modelSameCityDeliveryFreight')"
                    >
                      <el-option
                        v-for="item in YFCityOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-radio v-model="modelSameCityDeliveryExpressType" label="1" :disabled="radio1=='0'">同城自营骑手配送</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="6">
                    <el-select
                      ref="freightCityId"
                      v-model="modelSameCityDeliveryBySelfFreightId"
                      :disabled="radio1=='0'||(radio1=='1' && modelSameCityDeliveryExpressType=='0')"
                      placeholder="选择运费模板"
                      style="width:200px"
                      @focus="showDialogYF(1,'modelSameCityDeliveryBySelfFreight')"
                    >
                      <el-option
                        v-for="item in YFCityOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-col>
                </el-col>
              </el-col>
              <el-col v-if="type=='sale'||(type=='lease' && BindForm.isRecovery=='0') || (type=='lease' && !BindForm.isRecovery)" :span="1">取回</el-col>
              <el-col v-if="type=='sale'||(type=='lease' && BindForm.isRecovery=='0') || (type=='lease' && !BindForm.isRecovery)" :span="23">
                <el-col :span="24">
                  <el-radio v-model="modelSameCityRecoveryExpressType" label="0" :disabled="radio1=='0'">同城物流售后取回</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="4">
                    <el-select v-model="modelSameCityRecoveryExpressCompany" :disabled="radio1=='0' || (radio1=='1' && modelSameCityRecoveryExpressType=='1')">
                      <el-option
                        label="顺丰"
                        value="0"
                      >
                        顺丰
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6">
                    <el-select
                      ref="freightCityId"
                      v-model="modelSameCityRecoveryExpressFreightId"
                      class="margin-left"
                      :disabled="radio1=='0' || (radio1=='1' && modelSameCityRecoveryExpressType=='1')"
                      placeholder="选择运费模板"
                      style="width:200px"
                      @focus="showDialogYF(1,'modelSameCityRecoveryExpressFreight')"
                    >
                      <el-option
                        v-for="item in YFCityOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-radio v-model="modelSameCityRecoveryExpressType" label="1" :disabled="radio1=='0'">同城自营骑手售后取回</el-radio>
                </el-col>
                <el-col :span="24">
                  <el-col :span="6">
                    <el-select
                      ref="freightCityId"
                      v-model="modelSameCityRecoveryByselfFreightId"
                      class="margin-left"
                      :disabled="radio1=='0' || (radio1=='1' && modelSameCityRecoveryExpressType=='0')"
                      placeholder="选择运费模板"
                      style="width:200px"
                      @focus="showDialogYF(1,'modelSameCityRecoveryByselfFreight')"
                    >
                      <el-option
                        v-for="item in YFCityOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-col>
                </el-col>
              </el-col>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item v-if="BindForm.isRecovery==1" label="回收费用" prop="radio2">
          <el-row :gutter="24">
            <el-col :span="2" style="padding-left: 0;">
              <el-radio v-model="radio2" label="0" @change="changeCollectionExpress">统一费用</el-radio>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="24">
              <el-col v-for="(item,index) in collectionList" :key="index" :span="24">
                <collectionCost ref="collectionCost" :collection="item" />
              </el-col>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="2" style="padding-left: 12px;">
              <el-radio v-model="radio2" label="1" @change="changeCollectionExpress">运费模板</el-radio>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="24">
              <el-col v-for="(item,index) in collectionList" :key="index" :span="24">
                <CollectionModel ref="CollectionModel" :collection="item" />
              </el-col>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item>
          <el-row :gutter="24">
            <el-col :span="24" class="dispaly-flex el-col-margin">
              <el-button
                type="primary"
                size="medium"
                style="width:200px;margin:0px auto;"
                @click="submitCommodityShop"
              >提交</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </el-form>
    </div>

    <!--收费模板-->
    <el-dialog :visible.sync="chargeDialog" :modal="false">
      <div slot="title">
        <label>选择收费模板</label>
        <span class="margin-left" style="color:gray" />
      </div>
      <div class="key-title-search">
        <h4 />
        <div class="key-search">
          <el-input
            v-model="chargeKeyWords"
            suffix-icon="el-icon-search"
            placeholder="输入关键字搜索分类"
          />
          <el-button type="primary" @click="searchChargeDialog">确认</el-button>
          <el-button @click="resetCharge">重置</el-button>
        </div>
      </div>
      <el-table
        ref="elChargeTable"
        v-loading="chargeListLoading"
        :data="chargeList"
        :fit="true"
        element-loading-text="正在查询中。。。"
        stripe
        height="400"
      >
        <el-table-column label="名称" prop="name" />
        <el-table-column label="使用商品" prop="goodsCount" />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="primary" @click="selectChargeModel(scope.row)">选择模板</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="footer">
        <div>
          <el-button type="primary" @click="addChargeModel">新增模板</el-button>
          <el-button plain @click="resetCharge">刷新</el-button>
        </div>
        <div class="pagination">
          <div />
          <el-pagination
            background
            :page-sizes="[10, 20, 30, 50, 100]"
            :page-size="chargeLimit"
            :pager-count="5"
            layout="total, sizes, prev, pager, next, jumper"
            :total="chargeTotal"
            @size-change="chargePageSizeChange"
            @current-change="chargeCurrentPageChange"
          />
        </div>
      </div>
    </el-dialog>

    <!--运维费模板-->
    <el-dialog :visible.sync="visibleDialog2" :modal="false">
      <div slot="title">
        <label>选择运维费模板</label>
      </div>
      <div class="key-title-search">
        <div class="key-search">
          <div class="key-search-left" />
          <div class="ke-search-right">
            <el-input
              v-model="operateDialogKeyWords"
              suffix-icon="el-icon-search"
              placeholder="输入关键字搜索分类"
              class=""
            />
            <el-button type="primary" @click="searchOperateDialog">确认</el-button>
            <el-button @click="resetYWF">重置</el-button>
          </div>

        </div>
      </div>
      <el-table
        ref="elYWFTable"
        v-loading="YWFListLoading"
        :data="YWFList"
        :fit="true"
        element-loading-text="正在查询中。。。"
        stripe
        height="400"
      >
        <el-table-column label="名称" prop="name" />
        <el-table-column label="使用商品" prop="goodsCount" />
        <el-table-column label="模板类型" prop="type">
          <template slot-scope="scope">
            <span v-if="scope.row.type == '0'">售卖</span>
            <span v-if="scope.row.type == '1'">租赁</span>
          </template>
        </el-table-column>
        <el-table-column label="模板内容">
          <template slot-scope="scope">
            <span
              v-if="scope.row.type == '0'"
              style="display: flex; flex-wrap: wrap;  justify-content: space-around; white-space: nowrap;"
            >
              <span>配货:￥{{ scope.row.distributionPrice }}</span>
              <span>配送:￥{{ scope.row.deliveryPrice }}</span>
            </span>
            <span
              v-else
              style="display: flex; flex-wrap: wrap;  justify-content: space-around; white-space: nowrap;"
            >
              <span>配货:￥{{ scope.row.distributionPrice }}</span>
              <span>配送:￥{{ scope.row.deliveryPrice }}</span>
              <span>维护:￥{{ scope.row.maintainPrice }}</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="primary" @click="selectYWFModel(scope.row)">选择模板</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="footer">
        <div>
          <el-button type="primary" @click="addYWFModel">新增模板</el-button>
          <el-button plain @click="resetYWF">刷新</el-button>
        </div>
        <div class="pagination">
          <div />
          <el-pagination
            background
            :page-sizes="[10, 20, 30, 50, 100]"
            :page-size="YWFLimit"
            :pager-count="5"
            layout="total, sizes, prev, pager, next, jumper"
            :total="YWFTotal"
            @size-change="YWFPageSizeChange"
            @current-change="YWFCurrentPageChange"
          />
        </div>
      </div>
    </el-dialog>

    <!--云仓弹出框-->
    <add-cloud-store
      ref="AddCloudStore"
      :visible="cloudStockVisible"
      @handelClose="handelClose"
      @handelAllSelect="handelAllSelect"
    />
    <!-- 回收点弹框-->
    <AddCollection
      ref="AddCollection"
      :visible="collectionVisible"
      @handelClose="handelCollectionClose"
      @handelAllSelect="handelAllCollectionSelect"
    />
    <!-- 添加运费模板弹框-->
    <AddExpressModel
      ref="AddExpressModel"
      :visible="expressModelVisible"
      @getYFList="getYFOptions"
      @getYFCityList="getYFCityOptions"
      @getSelectYFModelByChar="getSelectYFModelByChar"
      @handelClose="handelExpressClose"
    />
  </div>

</template>

<script>
import { getShopID } from '@/utils/auth'
import { YWFTemplateList } from '@/views/shop/api/YWFTemplate'
import { getInfoById, postLinkShop } from '@/api/commodity'
import SpecItem from '@/components/SpecItem'
import GoodsDepositValue from '@/components/GoodsDepositValue'
import GoodsSalePriceValue from '@/components/GoodsSalePriceValue'
import GoodsStockValue from '@/components/GoodsStockValue'
import ExtraSpecItem from '@/views/Commodity/component/ExtraSpecItem'
import GoodsInfo from '@/components/GoodsInfo'
import ServiceInfo from '@/components/ServiceInfo'
import GoodsExtraSalePriceValue from '@/components/GoodsExtraSalePriceValue'
import GoodsExtraStockValue from '@/components/GoodsExtraStockValue'
import { collectMoneyTemplateList } from '@/views/shop/api/CollectMoneyTemplate'
import AddCollection from '@/components/AddCollection'
import AddCloudStore from '@/components/AddCloudStore'
import AddExpressModel from '@/components/AddExpressModel'
import CloudStoreExpress from '@/components/CloudStoreExpress'
import collectionCost from '@/components/CollectionCost'
import CollectionModel from '@/components/CollectionModel'
import CloudStoreExpressModel from '@/components/CloudStoreExpressModel'
import { Loading } from 'element-ui'
/** 门店管理 */
export default {
  name: 'AddGoodsShop',
  components: {
    GoodsStockValue,
    GoodsSalePriceValue,
    GoodsDepositValue,
    SpecItem,
    ExtraSpecItem,
    GoodsInfo,
    ServiceInfo,
    GoodsExtraSalePriceValue,
    GoodsExtraStockValue,
    AddCollection,
    AddCloudStore,
    AddExpressModel,
    CloudStoreExpress,
    collectionCost,
    CollectionModel,
    CloudStoreExpressModel
  },
  data() {
    var validateStock = (rule, value, callback) => {
      if (!this.BindForm.deliverStore && !this.BindForm.chainLock && !this.BindForm.cabinetLock && !this.BindForm.cloudLock) {
        callback(new Error('请至少选择一个仓库库存'))
      } else {
        callback()
      }
    }
    var validateRegular = (rule, value, callback) => {
      this.$refs.GoodsStockValue.forEach((item, index, arr) => {
        callback()
        /* if (this.type === 'lease') {
          if (!this.$refs.GoodsDepositValue[index].getData() || !this.$refs.GoodsStockValue[index].getData()) {
            callback(new Error('请补全规格数据'))
          } else {
            callback()
          }
        } else if (this.type === 'sale') {
          if (!this.$refs.GoodsSalePriceValue[index].getData() || !this.$refs.GoodsStockValue[index].getData()) {
            callback(new Error('请补全规格数据'))
          } else {
            callback()
          }
        }*/
      })
    }
    /* var validateExpress = (rule, value, callback) => {
      if (this.radio1 === '0') {
        if (this.sameCityCost && this.expressCost) {
          callback()
        } else if (this.sameCityCost && !this.expressCost) {
          callback(new Error('快递物流不能为空'))
        } else if (!this.sameCityCost && this.expressCost) {
          callback(new Error('同城配送不能为空'))
        } else {
          callback(new Error('快递物流、同城配送不能为空'))
        }
      } else if (this.radio1 === '1') {
        if (this.BindForm.freightId && this.BindForm.freightCityId) {
          callback()
        } else if (this.BindForm.freightId && !this.BindForm.freightCityId) {
          callback(new Error('请选择同城配送模板'))
        } else if (!this.BindForm.freightId && this.BindForm.freightCityId) {
          callback(new Error('请选择快递物流模板'))
        } else {
          callback(new Error('请选择同城配送和快递物流的模板'))
        }
      } else {
        callback(new Error('请选择配送费用'))
      }
    }*/

    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      shopPic: '',
      shopId: '',
      shopName: '',
      shopUrl: '',
      commodityId: '',
      type: '',
      commodityName: '',
      commodityPic: '',
      chainLockStock: '',
      cabinetLockStock: '',
      cloudLock: '',
      cloudLockStock: '',
      showShopList: [],
      dialogShopList: [],
      visibleDialog: false,
      visibleDialog2: false,
      disabled: false,
      stockDisabled: false,
      currentPage: '1',
      isAfterPay: null,
      isModelAfterPay: null,

      imgList: [],
      tableList: [],
      theadList: [],
      tbodyList: [],
      regularProductId: [],
      extraProductId: [],
      list: [],
      goodsSpecList: [],

      extraList: [],
      extraTable: [],
      extraGoods: [],
      cloudStoreList: [],

      commoditySale: {
        name: '零售价格',
        values: [
          {
            val: 'salePrice'
          }
        ]
      },
      deposit: {
        name: '押金',
        values: [
          {
            val: 'deposit'
          }
        ]
      },
      stock: {
        name: '库存',
        values: [
          {
            val: 'stock'
          }
        ]
      },
      goodsSpecPriceList: [],

      BindForm: {
        onlyToHospital: null,
        deliverStore: '',
        goodsStock: '',
        chainLock: '',
        cabinetLock: '',
        cloudLock: '',
        freeType: '',
        freeShip: '',
        freeCount: '',
        freeDelivery: '',
        freeDeliveryCount: '',
        freePick: '',
        freePickCount: '',

        retailPrice: '',

        operateId: '',
        freightId: '',
        freightCityId: '',
        chargeId: '',
        noDepositStat: '0',
        isRecovery: null,
        recoveryPrice: null
      },
      expressCost: '',
      sameCityCost: '',
      sendFastestTime: 0,
      sendSlowestTime: 24,
      radio1: '1',

      /** 同城配送参数 - 统一运费*/
      TySameCityDeliveryExpressType: '0', // 同城物流配送或同城自营骑手配送
      TyIsAfterPay: null,
      TySameCityDeliveryExpressCompany: '0', // 同城物流配送公司
      TySameCityDeliveryExpressCost: null, // 同城物流配送费用
      TySameCityDeliverySendFastTime: 0, // 同城物流配送最快时间
      TySameCityDeliverySendSlowTime: 24, // 同城物流配送最晚时间
      TySameCityDeliveryBySelfCost: null, // 同城自营骑手配送费用
      TySameCityByselfsendFastTime: 0, // 同城自营骑手配送最快时间
      TySameCityByselfsendSlowTime: 24, // 同城自营骑士配送最晚时间

      TySameCityRecoveryExpressType: '0', // 同城物流售后回收或同城自营骑手回收(0-同城物流售后回收 1-同城自营骑手回收)
      TySameCityRecoveryExpressCompanyId: '0', // 同城物流售后公司Id
      TySameCityRecoveryExpressCost: null, // 同城物流回收价格
      TySameCityRecoveryByselfCost: null, // 同城自营骑手回收价格

      /** 同城配送参数 - 运费模板*/
      modelSameCityDeliveryExpressType: '0', // 运费模板同城物流配送
      modelSameCityDeliveryExpressCompany: '0', // 运费模板同城配送物流公司
      modelSameCityRecoveryExpressCompany: '0', // 运费模板同城取回物流公司
      modelSameCityDeliveryBySelfFreightId: null, // 运费模板同城自营骑手发货模板

      modelSameCityRecoveryExpressType: '0', // 运费模板取回类型
      modelSameCityRecoveryExpressFreightId: null, // 运费模板取回快递物流模板
      modelSameCityDeliveryFreightId: null, // 运费模板发货快递物流模板
      modelSameCityRecoveryByselfFreightId: null, // 运费模板同城自营骑手取回模板

      /** 回收点参数*/
      collectionList: [],
      radio2: '0',

      /** 运维费模板*/
      YWFOptions: [],
      operateDialogKeyWords: '',
      YWFLimit: 10,
      YWFPage: 1,
      YWFTotal: 0,
      YWFType: '',
      YWFListLoading: true,
      YWFList: [],

      /** 收费模板*/
      chargeDialog: false,
      chargeOptions: [],
      chargeKeyWords: '',
      chargeLimit: 10,
      chargePage: 1,
      chargeTotal: 0,
      chargeListLoading: true,
      chargeList: [],

      /** 运费模板*/
      expressModelVisible: false,
      YFType: '',
      YFOptions: [],
      YFCityOptions: [],
      YFList: [],

      /** 云仓模板*/
      cloudStockVisible: false,
      /** 回收点模板*/
      collectionVisible: false,
      rules: {
        stock: [
          { required: true, validator: validateStock }
        ],
        chargeId: [
          { required: true, message: '请选择收费方式', trigger: 'change' }
        ],
        operateId: [
          { required: true, message: '请选择运维模板', trigger: 'change' }
        ],
        regularSpec: [
          { required: true, validator: validateRegular }
        ],
        /* radio1: [
          { required: true, validator: validateExpress }
        ],*/
        onlyToHospital: [
          { required: true, message: '请选择只支持医院类型', trigger: 'change' }
        ],
        noDepositStat: [
          { required: true, message: '请选择免押状态', trigger: 'change' }
        ],
        isRecovery: [
          { required: true, message: '请选择是否设置回收点', trigger: 'change' }
        ],
        recoveryPrice: [
          { required: true, message: '请输入回收价格', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    'BindForm.isRecovery': {
      handler(newValue, oldValue) {
        if (this.BindForm.isRecovery == '1' && this.BindForm.cloudLock && this.cloudStoreList.length > 0) {
          this.$nextTick(() => {
            if (this.$refs.cloudStoreExpress.length && this.$refs.cloudStoreExpress.length > 0) {
              this.$refs.cloudStoreExpress.forEach(item => {
                item.setIsRecovery(1)
              })
            } else if (!this.$refs.cloudStoreExpress.length) {
              this.$refs.cloudStoreExpress.setIsRecovery(1)
            }
            if (this.$refs.cloudStoreExpressModel.length && this.$refs.cloudStoreExpressModel.length > 0) {
              this.$refs.cloudStoreExpressModel.forEach(item => {
                item.setIsRecovery(1)
              })
            } else if (!this.$refs.cloudStoreExpressModel.length) {
              this.$refs.cloudStoreExpressModel.setIsRecovery(1)
            }
          })
        } else if (this.BindForm.isRecovery == '0' && this.BindForm.cloudLock && this.cloudStoreList.length > 0) {
          this.$nextTick(() => {
            if (this.$refs.cloudStoreExpress.length && this.$refs.cloudStoreExpress.length > 0) {
              this.$refs.cloudStoreExpress.forEach(item => {
                item.setIsRecovery(0)
              })
            } else if (!this.$refs.cloudStoreExpress.length) {
              this.$refs.cloudStoreExpress.setIsRecovery(0)
            }
            if (this.$refs.cloudStoreExpressModel.length && this.$refs.cloudStoreExpressModel.length > 0) {
              this.$refs.cloudStoreExpressModel.forEach(item => {
                item.setIsRecovery(0)
              })
            } else if (!this.$refs.cloudStoreExpressModel.length) {
              this.$refs.cloudStoreExpressModel.setIsRecovery(0)
            }
          })
        }
      },
      deep: true,
      immediate: true
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      const params = this.$dd(this.$route.query.p)
      this.commodityPic = params.commodityInfo.goodsImg
      this.commodityId = params.commodityInfo.goodsId
      this.commodityName = params.commodityInfo.goodsName
      this.type = params.commodityInfo.type
      this.shopId = params.shopInfo.storeId || params.shopInfo.id
      this.shopName = params.shopInfo.storeName
      this.shopAddress = params.shopInfo.addess
      console.log(params)
      if (this.type === 'lease') {
        this.YWFType = 1
      } else {
        this.YWFType = 0
      }
      const loadingInstance = Loading.service({ fullscreen: true })
      getInfoById({ goodsId: this.commodityId }).then(response => {
        loadingInstance.close()
        console.log(response.data.data)
        response.data.data.regualrCombo.forEach(item => {
          this.regularProductId.push(item.productId)
        })
        this.loadGoodsSpec(response.data.data.regualrList)
        const extraList = []
        /* const extraList = response.data.data.extral*/
        if (extraList && extraList.length > 0) {
          this.extraList = extraList
          this.loadExtraSpec(this.extraList)
        }
      }).catch(res => {
        loadingInstance.close()
        this.$message.error('无法新增商品门店，获取商品信息失败')
        this.$store.dispatch('tagsView/delView', this.$route)
        this.$router.go(-1)
      })
    },

    changeDisable() {
      this.disabled = true
    },
    changeStockDisable() {
      this.stockDisabled = true
    },
    /** 常规规格加载方法*/
    loadGoodsSpec(a) {
      a.forEach(item => {
        this.list.push(item)
      })
      this.$nextTick(() => {
        for (let i = 0; i < this.list.length; i++) {
          this.$refs.SpecItem[i].$data.tableHead.name = this.list[i].name
          this.$refs.SpecItem[i].$data.tableHead.values = this.list[i].valueList
          for (let j = 0; j < this.list[i].valueList.length; j++) {
            this.$refs.SpecItem[i].$data.tableHead.values[j].val = this.list[i].valueList[j].value
          }
        }
        console.log(this.$refs.SpecItem)
        this.createTable()
      })
    },
    // 创建表格
    createTable() {
      this.tableList = []
      if (this.list && this.list.length !== 0) {
        this.$refs.SpecItem.forEach(item => {
          this.tableList.push(item.getData())
          console.log(item)
        })
      }
      console.log(this.tableList)
      const arrList = []
      const headList = []
      if (this.type === 'lease') {
        this.tableList.push(this.deposit, this.stock)
      } else if (this.type === 'sale') {
        this.tableList.push(this.commoditySale, this.stock)
      }
      this.tableList.forEach(item => {
        if (item.name) {
          headList.push(item.name)
          if (item.values && item.values.length !== 0) {
            arrList.push(item.values)
          }
        }
      })
      this.theadList = headList

      const modelList = this.cartesianProductOf(...arrList)
      const list = []
      const count = 1

      for (let i = 0; i < modelList.length; i++) {
        const modelArrList = []
        for (let k = 0; k < modelList[i].length; k++) {
          modelArrList.push({
            val: modelList[i][k].val,
            commodityId: '',
            index: k,
            rowspan: count
          })
        }
        list.push(modelArrList)
      }
      console.log(list)
      this.tableRowspan(list, modelList)

      this.tbodyList = list
    },
    // table合并行方法 a为table数组 b为对比数组
    tableRowspan(a, b) {
      for (let i = 0; i < a.length - 1; i++) {
        for (let k = 0; k < a[i].length; k++) {
          for (let j = i + 1; j < b.length; j++) {
            if (k === 0) {
              if (a[i][k].val === b[j][k].val) {
                a[i][k].rowspan++
                a[j][k].val = ''
              } else {
                console.log({ i, j, k })
                break
              }
            } else {
              if (a[i][k].val === b[j][k].val && a[j][k - 1].val === '') {
                a[i][k].rowspan++
                a[j][k].val = ''
              } else {
                console.log({ i, j, k })
                break
              }
            }
          }
        }
      }
    },
    // 笛卡尔积
    cartesianProductOf() {
      return Array.prototype.reduce.call(arguments, function(a, b) {
        const ret = []
        a.forEach(function(a) {
          b.forEach(function(b) {
            ret.push(a.concat([b]))
          })
        })
        return ret
      }, [[]])
    },
    /** 加载附加规格*/
    loadExtraSpec(a) {
      this.$nextTick(() => {
        for (let i = 0; i < a.length; i++) {
          this.$refs.ExtraSpecItem[i].$data.tableHead.name = a[i].name
          if (a[i].type === 'custom') {
            this.$refs.ExtraSpecItem[i].$data.tableHead.type = '1'
          } else if (a[i].type === 'online') {
            this.$refs.ExtraSpecItem[i].$data.tableHead.type = '2'
          }
          this.$refs.ExtraSpecItem[i].$data.tableHead.isRequired = JSON.stringify(a[i].mustSelect)
          this.$refs.ExtraSpecItem[i].$data.tableHead.multiSelFlg = JSON.stringify(a[i].multiSelFlg)
          this.$refs.ExtraSpecItem[i].$data.tableHead.values = a[i].values
          for (let j = 0; j < a[i].values.length; j++) {
            this.$refs.ExtraSpecItem[i].$data.tableHead.values[j].val = a[i].values[j].value
          }
        }
        this.createExtraTable(a)
      })
    },
    /** 创建附加规格表格*/
    createExtraTable(a) {
      const extraTable = []
      for (let i = 0; i < a.length; i++) {
        const tbody = {
          specName: this.$refs.ExtraSpecItem[i].getData().name,
          specValue: []
        }
        console.log(a[i])
        for (let j = 0; j < a[i].values.length; j++) {
          const spec = {
            value: this.$refs.ExtraSpecItem[i].getData().values[j].val,
            goods: '',
            salePrice: 'salePrice',
            stock: 'stock',
            commodityid: a[i].values[j].commodityid
            /* productId: a[i].values[j].productId,*/
            /* serviceid: ''*/
          }
          if (this.$refs.ExtraSpecItem[i].getData().type === '1') {
            spec.goods = 'goods'
          } else {
            spec.goods = 'service'
          }

          tbody.specValue.push(spec)
        }
        extraTable.push(tbody)
      }
      this.extraTable = extraTable
      console.log(extraTable)
    },

    showDialogShopList() {
      this.dialogVisible = true
      this.getDialogList()
    },

    delSelectShop(index) {
      this.dialogShopList.splice(index, 1)
      console.log(this.dialogShopList)
      this.showShopList = []
      if (this.dialogShopList.length <= 3) {
        this.showShopList = this.dialogShopList
      } else {
        for (let i = 0; i < 3; i++) {
          this.showShopList.push(this.dialogShopList[i])
        }
      }
    },
    /** 运维费模板方法*/
    showDialogOperate() {
      this.visibleDialog2 = true
      this.getYWFList()
    },
    searchOperateDialog() {
      this.YWFReloadTableData()
    },
    resetYWF() {
      this.operateDialogKeyWords = ''
      this.YWFReloadTableData()
    },
    YWFPageSizeChange(pageSize) {
      this.YWFLimit = pageSize
      this.YWFReloadTableData()
    },
    YWFCurrentPageChange(page) {
      this.YWFPage = page
      this.getYWFList()
    },
    YWFReloadTableData() {
      this.YWFPage = 1
      this.YWFTotal = 0
      this.YWFList = []
      this.getYWFList()
    },
    getYWFList() {
      const data = {
        shopId: getShopID(),
        keySearch: '',
        type: this.YWFType,
        page: this.YWFPage,
        limit: this.YWFLimit
      }
      if (this.operateDialogKeyWords) {
        data.keySearch = this.operateDialogKeyWords
      }
      YWFTemplateList(data).then(response => {
        this.YWFList = response.data.data.data
        response.data.data.data.forEach(item => {
          const option = {
            value: item.id,
            label: item.name
          }
          this.YWFOptions.push(option)
        })
        this.YWFTotal = response.data.data.total
        this.YWFListLoading = false
      }).catch(() => {
        this.YWFList = []
        this.YWFTotal = 0
        this.YWFListLoading = false
      })
    },
    addYWFModel() {
      this.visibleDialog2 = false
      this.$router.push({ name: 'AddYWFTemplate' })
    },
    selectYWFModel(row) {
      this.visibleDialog2 = false
      this.YWFOptions.forEach(item => {
        if (item.value === row.id) {
          this.BindForm.operateId = item.value
        }
      })
    },

    /** 收费费模板方法*/
    showDialogCharge(type) {
      this.chargeDialog = true
      this.getChargeList()
    },
    searchChargeDialog() {
      this.chargeReloadTableData()
    },
    resetCharge() {
      this.chargeKeyWords = ''
      this.chargeReloadTableData()
    },
    chargePageSizeChange(pageSize) {
      this.chargeLimit = pageSize
      this.chargeReloadTableData()
    },
    chargeCurrentPageChange(page) {
      this.chargePage = page
      this.getChargeList()
    },
    chargeReloadTableData() {
      this.chargePage = 1
      this.chargeTotal = 0
      this.chargeList = []
      this.getChargeList()
    },
    getChargeList() {
      const data = {
        shopId: localStorage.getItem('shopId'),
        keySearch: '',
        page: this.chargePage,
        limit: this.chargeLimit
      }
      if (this.chargeKeyWords) {
        data.keySearch = this.chargeKeyWords
      }
      collectMoneyTemplateList(data).then(inf => {
        this.chargeList = inf.data.data.data
        this.chargeTotal = inf.data.data.total
        console.log(this.chargeList)
        inf.data.data.data.forEach(item => {
          const option = {
            value: item.id,
            label: item.name
          }
          this.chargeOptions.push(option)
        })
        this.chargeListLoading = false
      })
    },
    addChargeModel() {
      this.chargeDialog = false
      this.$router.push({ name: 'AddCollectMoney' })
    },
    selectChargeModel(row) {
      this.chargeDialog = false
      this.chargeOptions.forEach(item => {
        if (item.value === row.id) {
          this.BindForm.chargeId = item.value
        }
      })
    },

    /** 运费模板方法*/
    /** 运费模板方法*/
    showDialogYF(number, string) {
      this.expressModelVisible = true
      this.$refs.AddExpressModel.setReChar(string)
      this.$refs.AddExpressModel.setYFType(number)
      this.$refs.AddExpressModel.resetYF()
      this.YFType = number
    },
    getYFOptions(list) {
      this.YFOptions = list
    },
    getYFCityOptions(list) {
      this.YFCityOptions = list
    },
    getSelectYFModelByChar(data, string) {
      if (string == 'modelSameCityDeliveryFreight') {
        this.modelSameCityDeliveryFreightId = data.id
      } else if (string == 'modelSameCityDeliveryBySelfFreight') {
        this.modelSameCityDeliveryBySelfFreightId = data.id
      } else if (string == 'modelSameCityRecoveryExpressFreight') {
        this.modelSameCityRecoveryExpressFreightId = data.id
      } else if (string == 'modelSameCityRecoveryByselfFreight') {
        this.modelSameCityRecoveryByselfFreightId = data.id
      }
    },
    handelExpressClose() {
      this.expressModelVisible = false
    },

    /** 添加云仓功能*/
    addCloudStore() {
      this.cloudStockVisible = true
      if (this.cloudStoreList.length > 0) {
        this.$refs.AddCloudStore.setSelectList(this.cloudStoreList)
        this.$refs.AddCloudStore.resetForm()
      }
    },
    /** 关闭云仓弹出框*/
    handelClose() {
      this.cloudStockVisible = false
    },
    /** 传递云仓列表*/
    handelAllSelect(list) {
      if (list.length > 0) {
        this.cloudStoreList = []
        list.forEach(row => {
          this.cloudStoreList.push({
            id: row.id,
            name: row.name
          })
        })
        if (this.radio1 == '0') {
          if (this.cloudStoreList.length > 0) {
            this.$nextTick(() => {
              this.$nextTick(() => {
                this.$refs.cloudStoreExpressModel.forEach(item => {
                  item.changeDisabled(true)
                })
              })
            })
          }
        } else if (this.radio1 == '1') {
          if (this.cloudStoreList.length > 0) {
            this.$nextTick(() => {
              this.$nextTick(() => {
                this.$refs.cloudStoreExpress.forEach(item => {
                  item.changeDisabled(true)
                })
              })
            })
          }
        }
        this.handelClose()
      }
    },

    /** 切换模板与统一费用*/
    changeExpress() {
      if (this.radio1 == '0') {
        if (this.cloudStoreList.length > 0) {
          this.$nextTick(() => {
            console.log(this.$refs.cloudStoreExpressModel)
            this.$refs.cloudStoreExpressModel.forEach(item => {
              item.changeDisabled(true)
            })
            this.$refs.cloudStoreExpress.forEach(item => {
              item.changeDisabled(false)
            })
          })
        }
      } else if (this.radio1 == '1') {
        if (this.cloudStoreList.length > 0) {
          this.$nextTick(() => {
            console.log(this.$refs.cloudStoreExpressModel)
            this.$refs.cloudStoreExpress.forEach(item => {
              item.changeDisabled(true)
            })
            this.$refs.cloudStoreExpressModel.forEach(item => {
              item.changeDisabled(false)
            })
          })
        }
      }
    },
    /** 切换收集点统一费用或运费模板*/
    changeCollectionExpress() {
      if (this.radio2 == '0') {
        if (this.collectionList.length > 0) {
          this.$nextTick(() => {
            console.log(this.$refs.collectionCost)
            this.$refs.collectionCost.forEach(item => {
              item.changeDisabled(false)
            })
            this.$refs.CollectionModel.forEach(item => {
              item.changeDisabled(true)
            })
          })
        }
      } else if (this.radio2 == '1') {
        if (this.collectionList.length > 0) {
          this.$nextTick(() => {
            console.log(this.$refs.collectionCost)
            this.$refs.collectionCost.forEach(item => {
              item.changeDisabled(true)
            })
            this.$refs.CollectionModel.forEach(item => {
              item.changeDisabled(false)
            })
          })
        }
      }
    },
    /** 删除当前云仓*/
    delCloudStore(index) {
      if (this.cloudStoreList.length > 0) {
        this.cloudStoreList.splice(index, 1)
      }
    },

    /** 添加回收点*/
    addCollection() {
      this.collectionVisible = true
      if (this.collectionList.length > 0) {
        this.$refs.AddCollection.setSelectList(this.collectionList)
        this.$refs.AddCollection.refresh()
      }
    },
    /** 关闭回收点列表*/
    handelCollectionClose() {
      this.collectionVisible = false
    },
    /** 传递回收点列表*/
    handelAllCollectionSelect(list) {
      if (list.length > 0) {
        this.collectionList = []
        list.forEach(row => {
          this.collectionList.push(row)
        })
        if (this.radio2 == '0') {
          if (this.collectionList.length > 0) {
            this.$nextTick(() => {
              this.$nextTick(() => {
                this.$refs.collectionCost.forEach(item => {
                  item.changeDisabled(false)
                })
                this.$refs.CollectionModel.forEach(item => {
                  item.changeDisabled(true)
                })
              })
            })
          }
        } else if (this.radio2 == '1') {
          if (this.collectionList.length > 0) {
            this.$nextTick(() => {
              this.$nextTick(() => {
                this.$refs.collectionCost.forEach(item => {
                  item.changeDisabled(true)
                })
                this.$refs.CollectionModel.forEach(item => {
                  item.changeDisabled(false)
                })
              })
            })
          }
        }
        this.handelCollectionClose()
      }
    },
    /** 删除回收点*/
    delCollection(index) {
      console.log(this.collectionList)
      if (this.collectionList.length > 0) {
        this.collectionList.splice(index, 1)
      }
    },

    submitCommodityShop() {
      if (!this.BindForm.onlyToHospital) {
        return this.$message.error('只支持医院类型不能为空')
      }
      if (!this.BindForm.deliverStore && !this.BindForm.chainLock && !this.BindForm.cabinetLock && !this.BindForm.cloudLock) {
        return this.$message.error('请至少选择一个仓库类型')
      }
      if (this.BindForm.cloudLock) {
        if (this.cloudStoreList.length == 0) {
          return this.$message.error('请选择发货的云仓')
        }
      }
      let freeDeliveryType = ''
      if (this.BindForm.freeType && !this.BindForm.freeShip && !this.BindForm.freePick) {
        return this.$message.error('请至少选择一种类型')
      }
      if (this.BindForm.freeType && this.BindForm.freeShip === '1') {
        freeDeliveryType = 1
      } else if (this.BindForm.freeType && this.BindForm.freeShip === '2') {
        freeDeliveryType = 2
        if (!this.BindForm.freeCount) {
          if (this.type === 'sale') {
            return this.$message.error('满运费金额不能为空')
          } else if (this.type === 'lease') {
            return this.$message.error('满送货费金额不能为空')
          }
        }
      } else {
        freeDeliveryType = 0
      }
      let freePickType = ''
      if (this.BindForm.freeType && this.BindForm.freePick === '1') {
        freePickType = 1
      } else if (this.BindForm.freeShip && this.BindForm.freePick === '2') {
        freePickType = 2
        if (!this.BindForm.freePickCount) {
          return this.$message.error('满取货费金额不能为空')
        }
      } else {
        freePickType = 0
      }

      this.$nextTick(() => {
        const productList = []

        if (this.type === 'lease') {
          if (!this.BindForm.noDepositStat) {
            return this.$message.error('请选择一种免押状态')
          }
          for (let i = 0; i < this.$refs.GoodsDepositValue.length; i++) {
            if (this.$refs.GoodsDepositValue[i].commodityId === this.$refs.GoodsStockValue[i].commodityId) {
              if (!this.$refs.GoodsStockValue[i].getData() && this.$refs.GoodsDepositValue[i].getData()) {
                return this.$message.error('常规规格库存未补全')
              } else if (!this.$refs.GoodsDepositValue[i].getData() && this.$refs.GoodsStockValue[i].getData()) {
                return this.$message.error('常规规格押金未补全')
              } else if (!this.$refs.GoodsDepositValue[i].getData() && !this.$refs.GoodsStockValue[i].getData()) {
                return this.$message.error('常规规格押金/库存未补全')
              } else {
                const productInfo = {
                  productId: this.$refs.GoodsDepositValue[i].commodityId,
                  stock: this.$refs.GoodsStockValue[i].getData(),
                  price: '',
                  deposit: this.$refs.GoodsDepositValue[i].getData()
                }
                productList.push(productInfo)
              }
            }
          }
        } else if (this.type === 'sale') {
          for (let i = 0; i < this.$refs.GoodsStockValue.length; i++) {
            if (this.$refs.GoodsSalePriceValue[i].commodityId === this.$refs.GoodsStockValue[i].commodityId) {
              if (!this.$refs.GoodsStockValue[i].getData() && this.$refs.GoodsSalePriceValue[i].getData()) {
                return this.$message.error('常规规格库存未补全')
              } else if (!this.$refs.GoodsSalePriceValue[i].getData() && this.$refs.GoodsStockValue[i].getData()) {
                return this.$message.error('常规规格零售价格未补全')
              } else if (!this.$refs.GoodsSalePriceValue[i].getData() && !this.$refs.GoodsStockValue[i].getData()) {
                return this.$message.error('常规规格零售价格/库存未补全')
              } else {
                const productInfo = {
                  productId: this.$refs.GoodsSalePriceValue[i].commodityId,
                  stock: this.$refs.GoodsStockValue[i].getData(),
                  price: this.$refs.GoodsSalePriceValue[i].getData(),
                  deposit: ''
                }
                productList.push(productInfo)
              }
            }
          }
        }
        /* if (this.extraList && this.extraList.length > 0) {
          for (let i = 0; i < this.$refs.GoodsExtraSalePriceValue.length; i++) {
            if (this.$refs.GoodsExtraSalePriceValue[i].productId === this.$refs.GoodsExtraStockValue[i].productId) {
              if (!this.$refs.GoodsExtraStockValue[i].getData() && this.$refs.GoodsExtraSalePriceValue[i].getData()) {
                return this.$message.error('附加规格库存未补全')
              } else if (!this.$refs.GoodsExtraSalePriceValue[i].getData() && this.$refs.GoodsExtraStockValue[i].getData()) {
                return this.$message.error('附加规格零售价格未补全')
              } else if (!this.$refs.GoodsExtraSalePriceValue[i].getData() && !this.$refs.GoodsExtraStockValue[i].getData()) {
                return this.$message.error('附加规格零售价格/库存未补全')
              } else {
                const productInfo = {
                  productId: this.$refs.GoodsExtraSalePriceValue[i].productId,
                  stock: this.$refs.GoodsExtraStockValue[i].getData(),
                  price: this.$refs.GoodsExtraSalePriceValue[i].getData()
                }
                productList.push(productInfo)
              }
            }
          }
        }*/
        if (this.type === 'lease' && !this.BindForm.chargeId) {
          return this.$message.error('请选择收费方式')
        }
        if (!this.BindForm.operateId) {
          return this.$message.error('请选择运维费用')
        }
        if (this.type == 'lease') {
          if (this.BindForm.isRecovery == '1') {
            if (!this.BindForm.recoveryPrice) {
              return this.$message.error('请输入回收点价格')
            }
            if (this.collectionList.length == 0) {
              return this.$message.error('请至少添加一个回收点')
            }
          }
        }
        if (this.radio1 === '0') {
          if (this.type == 'lease') {
            if (!this.TyIsAfterPay) {
              return this.$message.error('请选择先付后付类型')
            }
          }
        } else if (this.radio1 === '1') {
          if (this.type == 'lease') {
            if (!this.isModelAfterPay) {
              return this.$message.error('请选择先付后付类型')
            }
          }
        }

        if (this.radio1 == '0') {
          if (this.TySameCityDeliveryExpressType == '0') {
            if (!this.TySameCityDeliveryExpressCompany) {
              return this.$message.error('请选择同城物流配送快递公司')
            }
            if (!this.TySameCityDeliveryExpressCost) {
              return this.$message.error('请输入同城物流配送费用')
            }
            if (!this.TySameCityDeliverySendFastTime) {
              return this.$message.error('请输入同城物流配送最快送达时间')
            }
            if (!this.TySameCityDeliverySendSlowTime) {
              return this.$message.error('请输入同城物流配送最晚送达时间')
            }
          } else if (this.TySameCityDeliveryExpressType == '1') {
            if (!this.TySameCityDeliveryBySelfCost) {
              return this.$message.error('请输入同城自营骑手配送费用')
            }
            if (!this.TySameCityByselfsendFastTime) {
              return this.$message.error('请输入同城自营骑手配送最快送达时间')
            }
            if (!this.TySameCityByselfsendSlowTime) {
              return this.$message.error('请输入同城自营骑手配送最晚送达时间')
            }
          }
          if (this.BindForm.isRecovery == '0' && this.type == 'lease') {
            if (this.TySameCityRecoveryExpressType == '0') {
              if (!this.TySameCityRecoveryExpressCompanyId) {
                return this.$message.error('请选择同城物流售后取回快递公司')
              }
              if (!this.TySameCityRecoveryExpressCost) {
                return this.$message.error('请输入同城物流售后取回费用')
              }
            } else if (this.TySameCityRecoveryExpressType == '1') {
              if (!this.TySameCityRecoveryByselfCost) {
                return this.$message.error('请输入同城自营骑手售后取回费用')
              }
            }
          }
        } else if (this.radio1 == '1') {
          if (this.modelSameCityDeliveryExpressType == '0') {
            if (!this.modelSameCityDeliveryExpressCompany) {
              return this.$message.error('请选择同城物流快递公司')
            }
            if (!this.modelSameCityDeliveryFreightId) {
              return this.$message.error('请选择同城物流快递模板')
            }
          } else if (this.modelSameCityDeliveryExpressType == '1') {
            if (!this.modelSameCityDeliveryBySelfFreightId) {
              return this.$message.error('请选择同城自营骑手运费模板')
            }
          }
          if (this.BindForm.isRecovery == '0' && this.type == 'lease') {
            if (this.modelSameCityRecoveryExpressType == '0') {
              if (!this.modelSameCityRecoveryExpressCompany) {
                return this.$message.error('请选择同城物流取回快递公司')
              }
              if (!this.modelSameCityRecoveryExpressFreightId) {
                return this.$message.error('请选择同城物流取回快递模板')
              }
            } else if (this.modelSameCityRecoveryExpressType == '1') {
              if (!this.modelSameCityRecoveryByselfFreightId) {
                return this.$message.error('请选择同城自营骑手取回模板')
              }
            }
          }
        }

        let goodsStock = -1
        if (this.BindForm.deliverStore && this.BindForm.goodsStock) {
          goodsStock = this.BindForm.goodsStock
        }
        this.$nextTick(() => {
          const cloudStoreList = []
          if (this.cloudStoreList.length > 0) {
            this.cloudStoreList.forEach(item => {
              cloudStoreList.push(item.id)
            })
          }
          const recoveryList = []
          if (this.type == 'lease') {
            if (this.collectionList.length > 0) {
              this.collectionList.forEach(item => {
                recoveryList.push(item.id)
              })
            }
          }
          const cloudStoreExpressList = []
          const modelCloudStoreExpressList = []
          if (this.cloudStoreList.length > 0) {
            if (this.$refs.cloudStoreExpress.length) {
              if (this.radio1 == '0') {
                this.$refs.cloudStoreExpress.forEach(item => {
                  console.log(item.getData())
                  cloudStoreExpressList.push(item.getData())
                })
              } else if (this.radio1 == '1') {
                this.$refs.cloudStoreExpressModel.forEach(info => {
                  console.log(info.getData())
                  modelCloudStoreExpressList.push(info.getData())
                })
              }
            }
          }
          let TySameCityDeliveryCost = null
          let TySameCityRecoveryCost = null
          let sendFastestTime = null
          let sendSlowestTime = null
          let modelSameCityDeliveryExpressId = null
          let modelSameCityRecoveryExpressId = null
          if (this.TySameCityDeliveryExpressType == '0') {
            TySameCityDeliveryCost = this.TySameCityDeliveryExpressCost
            sendFastestTime = this.TySameCityDeliverySendFastTime
            sendSlowestTime = this.TySameCityDeliverySendSlowTime
          } else if (this.TySameCityDeliveryExpressType == '1') {
            TySameCityDeliveryCost = this.TySameCityDeliveryBySelfCost
            sendFastestTime = this.TySameCityByselfsendFastTime
            sendSlowestTime = this.TySameCityByselfsendSlowTime
          }
          if (this.TySameCityRecoveryExpressType == '0') {
            TySameCityRecoveryCost = this.TySameCityRecoveryExpressCost
          } else if (this.TySameCityRecoveryExpressType == '1') {
            TySameCityRecoveryCost = this.TySameCityRecoveryByselfCost
          }
          if (this.modelSameCityDeliveryExpressType == '0') {
            modelSameCityDeliveryExpressId = this.modelSameCityDeliveryFreightId
          } else if (this.modelSameCityDeliveryExpressType == '1') {
            modelSameCityDeliveryExpressId = this.modelSameCityDeliveryBySelfFreightId
          }
          if (this.modelSameCityRecoveryExpressType == '0') {
            modelSameCityRecoveryExpressId = this.modelSameCityRecoveryExpressFreightId
          } else if (this.modelSameCityRecoveryExpressType == '1') {
            modelSameCityRecoveryExpressId = this.modelSameCityRecoveryByselfFreightId
          }
          const collectionPointList = []

          if (this.BindForm.isRecovery == '1') {
            if (this.collectionList.length > 0) {
              if (this.radio2 == '0') {
                if (this.$refs.collectionCost.length && this.$refs.collectionCost.length > 0) {
                  this.$refs.collectionCost.forEach(item => {
                    console.log(item.getData())
                    collectionPointList.push(item.getData())
                  })
                } else if (!this.$refs.collectionCost.length) {
                  console.log(this.$refs.collectionCost.getData())
                  collectionPointList.push(this.$refs.collectionCost.getData())
                }
              } else if (this.radio2 == '1') {
                if (this.$refs.CollectionModel.length && this.$refs.CollectionModel.length > 0) {
                  this.$refs.CollectionModel.forEach(item => {
                    console.log(item.getData())
                    collectionPointList.push(item.getData())
                  })
                } else if (!this.$refs.CollectionModel.length) {
                  console.log(this.$refs.CollectionModel.getData())
                  collectionPointList.push(this.$refs.CollectionModel.getData())
                }
              }
            }
          }
          const data = {
            shopIds: [this.shopId],
            commodityId: this.commodityId,
            goodsStock: goodsStock,
            chainLock: this.BindForm.chainLock ? 1 : 0,
            cabinetLock: this.BindForm.cabinetLock ? 1 : 0,
            cloudLock: this.BindForm.cloudLock ? 1 : 0,
            cloudStoreList: cloudStoreList.toString(),
            freeDeliveryType: freeDeliveryType,
            freeDeliveryPrice: this.BindForm.freeCount,
            freePickType: freePickType,
            freePickPrice: this.BindForm.freePickCount,
            retailPrice: this.BindForm.retailPrice,
            leaseChargeTemplateId: this.BindForm.chargeId,
            operateId: this.BindForm.operateId,
            isRecovery: this.BindForm.isRecovery,
            recoveryPrice: this.BindForm.recoveryPrice,
            recoveryList: recoveryList.toString(),
            logisticsType: this.radio1,
            flatFee: {
              payOrder: this.TyIsAfterPay,
              cloudStoreExpressList: cloudStoreExpressList,
              sameCityDelivery: {
                delivery: this.TySameCityDeliveryExpressType,
                deliveryExpressId: this.TySameCityDeliveryExpressCompany,
                deliveryCost: TySameCityDeliveryCost,
                sendFastestTime: sendFastestTime,
                sendSlowestTime: sendSlowestTime
              }
            },
            expressModel: {
              payOrder: this.isModelAfterPay,
              cloudStoreExpressList: modelCloudStoreExpressList,
              sameCityDelivery: {
                delivery: this.modelSameCityDeliveryExpressType,
                deliveryExpressId: this.modelSameCityDeliveryExpressCompany,
                deliveryModelId: modelSameCityDeliveryExpressId
              }
            },
            productList: productList,
            onlyToHospital: this.BindForm.onlyToHospital == '0' ? 0 : 1,
            noDepositStat: this.BindForm.noDepositStat
          }
          if (this.type == 'sale' || (this.type == 'lease' && this.BindForm.isRecovery == '0')) {
            data.flatFee.sameCityDelivery['recovery'] = this.TySameCityRecoveryExpressType
            data.flatFee.sameCityDelivery['recoveryExpressId'] = this.TySameCityRecoveryExpressCompanyId
            data.flatFee.sameCityDelivery['recoveryCost'] = TySameCityRecoveryCost
            data.expressModel.sameCityDelivery['recovery'] = this.modelSameCityRecoveryExpressType
            data.expressModel.sameCityDelivery['recoveryExpressId'] = this.modelSameCityRecoveryExpressCompany
            data.expressModel.sameCityDelivery['recoveryModelId'] = modelSameCityRecoveryExpressId
          } else if (this.type == 'lease' && this.BindForm.isRecovery == '1' && this.collectionList.length > 0) {
            data['recoveryFee'] = {
              recoveryType: this.radio2,
              recoveryList: collectionPointList
            }
          }
          if (this.radio1 == '0') {
            delete data.expressModel
          } else if (this.radio1 == '1') {
            delete data.flatFee
          }
          console.log(data)
          const loadingInstance = Loading.service({ fullscreen: true })
          postLinkShop(data).then(inf => {
            loadingInstance.close()
            console.log(inf.data)
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.go(-1)
          }).catch(res => {
            loadingInstance.close()
            if (res && res.data && res.data.errno !== 0) {
              this.$message.error(`${res.data.errmsg}（${res.data.errno}）`)
            }
          })
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.AddGoodsShop {
  min-width: 1700px;
  .left-end {
    text-align: end;
  }
  .margin-padding {
    margin: 0;
    padding: 0;
  }
  .dispaly-flex {
    display: flex;
    align-items: center;
  }
  .text {
    white-space: nowrap;
    color: gray;
  }
  .margin-left {
    margin-left: 12px;
  }
  padding: 50px 100px;
  .ele-store {
    display: flex;
    .ele-span-title {
      font-weight: bold;
      font-size: 18px;
      width: 60px;
    }
    .card-list {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      ::v-deep.el-card {
        margin-right: 20px;
        margin-bottom: 20px;
        width: auto !important;
        .el-card__header {
          border: none;
          padding: 0;
        }
        width: 350px;
        .ele-card-header {
          float: right;
        }
        .ele-content {
          display: flex;
          align-items: center;
          .left {
            width: 60px;
            height: 60px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .right {
            margin-left: 10px;
            p:first-child {
              font-weight: bold;
              font-size: 20px;
              margin: 0;
            }
            p:last-child {
              color: gray;
              font-size: 14px;
              margin: 10px 0px 0px 0px;
            }
          }
        }
        .ele-div--1 {
          display: flex;
          align-items: center;
          .left {
            width: 100px;
            height: 100px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .right {
            margin-left: 10px;
            p {
              font-size: 20px;
            }
            p:first-child {
              font-weight: bold;
              margin: 0;
              margin-bottom: 25px;
            }
            p:last-child {
              color: gray;
              margin: 10px 0px 0px 0px;
            }
          }
        }
      }
    }
  }
  .ele-commodity {
    .card-list {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      ::v-deep.el-card {
        margin-right: 2%;
        margin-bottom: 20px;
        .el-card__header {
          border: none;
          padding: 0;
        }
      }
    }
  }
  .formModel {
    width: 100%;
    ::v-deep.el-form {
      .el-form-item__content {
        margin-left: 95px;
      }
      .el-form-item {
        .el-form-item__label {
          width: 80px;
          text-align: start;
        }
        .el-col-margin {
          margin-top: 50px;
        }
      }
    }
  }
  ::v-deep.el-dialog {
    .key-title-search {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .key-search {
        .el-input {
          width: 200px;
        }
      }
    }
    .footer {
      margin-top: 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      div:first-child {
        .el-button {
          width: 100px;
        }
      }
    }
  }
  .ele-div-keysearch {
    display: flex;
    justify-content: space-between;
    .search-left {
      display: flex;
      ::v-deep.el-select,
      .ele-input,
      .el-button {
        margin-left: 15px;
      }
      ::v-deep.el-select {
        width: 100px;
      }
    }
    .search-flex {
      display: flex;
      ::v-deep.el-button {
        margin-left: 15px;
      }
    }
  }
  .Specifications {
    padding: 40px 20px;
    width: 100%;
    border: 1px solid #e6e6e6;
    .cations-tag {
      ::v-deep.el-row {
        margin-top: 15px;
      }
      .ele-col-item {
        width: 60px;
      }
    }
    /*::v-deep.el-button {
      width: 150px;
    }*/
  }
  .ele-table {
    width: 100%;
    margin-top: 40px;
    .ele-div-footer {
      display: flex;
      justify-content: space-between;
      margin: 50px 0px 100px 0px;
      .footer-left {
        ::v-deep.el-button {
          width: 100px;
          margin: 0px;
        }
      }
    }
  }
  .ele-spec-table {
    min-width: 100%;
    border-collapse: collapse;
    margin-top: 30px;
    tr td {
      width: 80px;
      border: 1px solid #e6e6e6;
      box-sizing: border-box;
      text-align: center;
    }
    thead {
      font-weight: bold;
      tr td {
        height: 60px;
      }
    }
    tbody {
      tr {
        td {
          ::v-deep.el-image {
            width: 50px;
            height: 50px;
            object-fit: cover;
            border: 1px solid #e6e6e6;
            overflow: unset;
            margin: 10px 0px;
          }
          ::v-deep.el-input {
            width: 120px;
          }
          .custom {
            display: flex;
            align-items: center;
            justify-content: center;
            span {
              margin-left: 5px;
            }
          }
        }
      }
    }
  }
}
</style>
